package com.example.it.adapter;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;

import com.example.it.bean.DataBean;

import java.util.ArrayList;

public class VpFragmentAdapter extends FragmentStatePagerAdapter {
    ArrayList<Fragment> fragments;
    ArrayList<DataBean>  data;

    public VpFragmentAdapter(@NonNull FragmentManager fm, ArrayList<Fragment> fragments, ArrayList<DataBean> data) {
        super(fm);
        this.fragments = fragments;
        this.data = data;
    }

    @NonNull
    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return fragments.size();
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return data.get(position).getName();
    }
}
